<?php 
	class SqlApi{
	public $connection;
	function __construct(){
		$this->connection=Yii::app()->db;
	}	
		
    public function fetch_rows($sql){
    	$cmd=$this->connection->createCommand($sql);
    	$ret=$cmd->queryAll();
    	return $ret; 
    }
		
	public function fetch_one($sql){
		$cmd=$this->connection->createCommand($sql);
	 	$ret=$cmd->queryRow();
	  	if($ret){
	  		return $ret;
	  	}else {
	  		return FALSE;
	  }
	}	

   public  function  fetch_one_cell($sql){
    	$cmd=$this->connection->createCommand($sql);
    	$ret=$cmd->queryScalar();
		return $ret;	
	}	
		
   public  function query($sql){
   		$cmd=$this->connection->createCommand($sql);
   		$ret=$cmd->execute();
   	}		
}
?>
